<div class="container">
    <h1 id="pkg-overview">package ecdsa</h1>
    <p><code>import "crypto/ecdsa"</code>
    </p><p>ecdsa包实现了椭圆曲线数字签名算法，参见FIPS 186-3。</p>
    
    
		
        
        
        
        
        
    
    <h2 id="PublicKey">type <a href="https://github.com/golang/go/blob/master/src/crypto/ecdsa/ecdsa.go?name=release#22" title="View Source">PublicKey</a> </h2>
    <pre>type PublicKey struct {
    <a href="crypto/elliptic.htm">elliptic</a>.<a href="crypto/elliptic.htm#Curve">Curve</a>
    <span id="PublicKey.X">X</span>, <span id="PublicKey.Y">Y</span> *<a href="math/big.htm">big</a>.<a href="math/big.htm#Int">Int</a>
}</pre>
    <p>PrivateKey代表一个ECDSA公钥。</p>
    <h2 id="PrivateKey">type <a href="https://github.com/golang/go/blob/master/src/crypto/ecdsa/ecdsa.go?name=release#28" title="View Source">PrivateKey</a> </h2>
    <pre>type PrivateKey struct {
    <a href="#PublicKey">PublicKey</a>
    <span id="PrivateKey.D">D</span>   *<a href="math/big.htm">big</a>.<a href="math/big.htm#Int">Int</a>
}</pre>
    <p>PrivateKey代表一个ECDSA私钥。</p>
    <h3 id="GenerateKey">func <a href="https://github.com/golang/go/blob/master/src/crypto/ecdsa/ecdsa.go?name=release#53" title="View Source">GenerateKey</a> </h3>
    <p>GenerateKey函数生成一对</p>
    <pre class="funcdecl">func GenerateKey(c <a href="crypto/elliptic.htm">elliptic</a>.<a href="crypto/elliptic.htm#Curve">Curve</a>, rand <a href="io.htm">io</a>.<a href="io.htm#Reader">Reader</a>) (priv *<a href="#PrivateKey">PrivateKey</a>, err <a href="builtin.htm#error">error</a>)</pre>
    <p>公钥/私钥。</p>
    <h2 id="Sign">func <a href="https://github.com/golang/go/blob/master/src/crypto/ecdsa/ecdsa.go?name=release#101" title="View Source">Sign</a> </h2>
    <pre class="funcdecl">func Sign(rand <a href="io.htm">io</a>.<a href="io.htm#Reader">Reader</a>, priv *<a href="#PrivateKey">PrivateKey</a>, hash []<a href="builtin.htm#byte">byte</a>) (r, s *<a href="math/big.htm">big</a>.<a href="math/big.htm#Int">Int</a>, err <a href="builtin.htm#error">error</a>)</pre>
    <p>使用私钥对任意长度的hash值（必须是较大信息的hash结果）进行签名，返回签名结果（一对大整数）。私钥的安全性取决于密码读取器的熵度（随机程度）。</p>
    <h2 id="Verify">func <a href="https://github.com/golang/go/blob/master/src/crypto/ecdsa/ecdsa.go?name=release#138" title="View Source">Verify</a> </h2>
    <pre class="funcdecl">func Verify(pub *<a href="#PublicKey">PublicKey</a>, hash []<a href="builtin.htm#byte">byte</a>, r, s *<a href="math/big.htm">big</a>.<a href="math/big.htm#Int">Int</a>) <a href="builtin.htm#bool">bool</a></pre>
    <p>使用公钥验证hash值和两个大整数r、s构成的签名，并返回签名是否合法。</p>
</div>